package com.ww.yaodao.config;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ww.yaodao.model.dto.ExcelDTO;
import com.ww.yaodao.service.FileUploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DataListener extends AnalysisEventListener<ExcelDTO> {

    public FileUploadService fileUploadService;

    public DataListener(FileUploadService fileUploadService) {
        this.fileUploadService = fileUploadService;
    }

    public DataListener() {
    }

    //读取excel内容，一行一行读取
    @Override
    public void invoke(ExcelDTO excelDTO, AnalysisContext analysisContext) {
        if (excelDTO == null) {
            try {
                throw new Exception("文件数据为空");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
